export const User = {
  state: {
    user: {},
    token: "",
  },

  mutations: {
    SAVE_TOKEN(state, token) {
      state.token = token;
    },

    SAVE_USER(state, user) {
      state.user = user;
    },
    UPDATE_USER(state, user){
      state.user = user
    },
    REMOVE_USER(state){
      state.user={}
    },
    REMOVE_TOKEN(state){
      state.token=''
    }
  },

  actions: {
    saveUser({ commit }, user) {
      commit("SAVE_USER", user);
    },
    updateUser({commit},user){
      commit('UPDATE_USER',user)
    },
    saveToken({ commit }, token) {
      commit("SAVE_TOKEN", token);
    },
    removeUser({commit}){
      commit('REMOVE_USER')
    },
    removeToken({commit}){
      commit('REMOVE_TOKEN')
    }
  },
};
